import React, { Component } from 'react'
import bus from '@/MyEvents'

export default class Child4 extends Component {
  state={
    msg:''
  }
  //当组件加载完毕后会调用
  componentDidMount(){
    bus.addListener('sendMsg',arg=>{
      console.log('arg',arg);
      this.setState({msg:arg})
    })
  }
  render() {
    return (
        <div style={{flexGrow:1,background:'yellow',height:'100vh'}}>
            <h1>子组件4</h1>
            <div>{this.state.msg}</div>
        </div>
    )
  }
}
